package com.ITArmy.service.impl;

import com.ITArmy.beans.Exchange;
import com.ITArmy.common.ServerResponse;
import com.ITArmy.dao.ExchangeMapper;
import com.ITArmy.service.ExchangeService;
import com.ITArmy.util.CheckMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ExchangeServiceImpl implements ExchangeService {

    @Autowired
    private ExchangeMapper exchangeMapper;

    //显示信息
    @Override
    public ServerResponse findExchange() {
        return ServerResponse.createBySuccess(exchangeMapper.selectExchange());
    }

    //修改信息
    @Override
    public ServerResponse updateExchange(Exchange exchange) {
            int resultCount = exchangeMapper.updateByPrimaryKeySelective(exchange);
            CheckMessage check=new CheckMessage();
            return check.getMessage(resultCount,"修改成功","修改失败");
    }

    //编辑时显示信息
    @Override
    public ServerResponse findExchangeById(Integer id) {
        return ServerResponse.createBySuccess(exchangeMapper.selectByPrimaryKey(id));
    }
}
